<template>
  <!-- 首页 -->
  <div class="father">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in info" :key="item.id">
        <van-image width="100%" height="100%" :src="url + item.imgSrc" />
      </van-swipe-item>
    </van-swipe>
    <div class="search">
      <div class="search-box">
        <div class="left" @click="$router.push('/city')">
          <span>{{ cityName }}</span>
          <van-icon
            class="iconfont"
            class-prefix="icon"
            name="xialakuangxiala"
            size="25"
            color="#000000"
          />
          <van-icon name="search" color="#c4c6c7" size="20" class="search" />
        </div>
        <input type="text" placeholder="请输入小区或地区" />
      </div>
    </div>
    <van-icon name="photo-o" size="30" color="#ffffff" class="map" />
    <div class="particulars">
      <ul>
        <li @click="$router.push('/find')">
          <div>
            <van-icon
              class="iconfont"
              class-prefix="icon"
              name="zufang1"
              size="30"
              color="#00ae66"
            />
            <p>整租</p>
          </div>
        </li>
        <li @click="$router.push('/find')">
          <div>
            <van-icon
              class="iconfont"
              class-prefix="icon"
              name="yunxuhezu"
              size="30"
              color="#00ae66"
            />
            <p>合租</p>
          </div>
        </li>
        <li>
          <div>
            <van-icon
              class="iconfont"
              class-prefix="icon"
              name="dituguanli"
              size="30"
              color="#00ae66"
            />
            <p>地图找房</p>
          </div>
        </li>
        <li @click="$router.push('/issue')">
          <div>
            <van-icon
              class="iconfont"
              class-prefix="icon"
              name="zufang"
              size="30"
              color="#00ae66"
            />
            <p>去出租</p>
          </div>
        </li>
      </ul>
    </div>
    <div class="more">
      <div class="more-header">
        <h4>租房小组</h4>
        <span>更多</span>
      </div>
      <div class="more-foot">
        <ul>
          <li v-for="item in cityUnit" :key="item.id">
            <img :src="url + item.imgSrc" alt="" />
            <div class="botton">
              <span>{{ item.title }}</span
              ><br />
              <span>{{ item.desc }}</span>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import { slideshow } from '@/api/login'
import { rentalUnit } from '@/api/city'
export default {
  name: 'homepage-page',
  async created () {
    const data = await slideshow()
    this.info = data.body
    const dataUnit = await rentalUnit()
    this.cityUnit = dataUnit.body
  },
  data () {
    return {
      value: '',
      info: {},
      url: 'http://liufusong.top:8080',
      cityUnit: ''
    }
  },
  methods: {
    onSearch () {
      console.log(this.value)
    }
  },
  computed: {
    ...mapState('user', ['cityName'])
  }
}
</script>

<style scoped lang="less">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.search {
  position: absolute;
  top: 15px;
  left: 10px;
  height: 40px;
  width: 90%;
  display: flex;
  justify-content: space-between;
  align-content: center;
  font-size: 14px;
  padding: 5px 0px 10px 0px;
  margin: 0px 18px;
  background-color: rgba(0, 0, 0, 0);
  .search-box {
    display: flex;
    padding: 5px 0;
    width: 280px;
    height: 30px;
    border-radius: 3px;
    background-color: #fff;
    .left {
      width: 60px;
      text-align: center;
      display: flex;
      border-right: 1px solid #ccc;
      .search {
        position: absolute;
        left: 50px;
        top: 5px;
      }
      span {
        position: relative;
        left: 10px;
        top: 1px;
        margin-right: 5px;
      }
    }
    input {
      position: absolute;
      right: 70px;
      top: 7px;
      z-index: 100;
      width: 180px;
      height: 26px;
      border: none;
      &::placeholder {
        position: absolute;
        top: 5px;
      }
    }
  }
}
.map {
  position: absolute;
  right: 20px;
  top: 20px;
  z-index: 1000;
}
.particulars {
  ul {
    display: flex;
    background-color: #fff;
    justify-content: space-between;
    height: 120px;
    li {
      flex: 1;
      text-align: center;
      div {
        margin: 10px auto;
        padding-top: 15px;
        background-color: #f2fbf7;
        width: 60px;
        height: 60px;
        border-radius: 50%;
      }
      p {
        font-size: 14px;
        flex-wrap: 400;
        margin-top: 18px;
      }
    }
  }
}
.more {
  height: 170px;
  width: 100%;
  background-color: #f6f5f6;
  padding: 1px 8px;
  font-size: 14px;
  .more-header {
    margin-left: 5px;
    display: flex;
    justify-content: space-between;
    margin: 12px 0 12px 10px;
  }
  .more-foot {
    ul {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      li {
        display: flex;
        width: 170px;
        height: 50px;
        margin-bottom: 8px;
        background-color: #fff;
        img {
          height: 40px;
          width: 50px;
          margin: auto 0;
        }
        .botton {
          margin-top: 8px;
          margin-left: 10px;
          font-size: 12px;
        }
      }
    }
  }
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  text-align: center;
}
</style>
